<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.9.1"/>
<title>restclient-cpp: include/restclient-cpp/helpers.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { init_search(); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">restclient-cpp
   </div>
   <div id="projectbrief">C++ client for making HTTP/REST requests</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.9.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_d44c64559bbebec7f509842c48db8b23.html">include</a></li><li class="navelem"><a class="el" href="dir_d7863d21b35bfd92001c24d3be435c80.html">restclient-cpp</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">helpers.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="helpers_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;</div>
<div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;<span class="preprocessor">#ifndef INCLUDE_RESTCLIENT_CPP_HELPERS_H_</span></div>
<div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;<span class="preprocessor">#define INCLUDE_RESTCLIENT_CPP_HELPERS_H_</span></div>
<div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;</div>
<div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;<span class="preprocessor">#include &lt;string&gt;</span></div>
<div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<span class="preprocessor">#include &lt;algorithm&gt;</span></div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;<span class="preprocessor">#include &lt;functional&gt;</span></div>
<div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;</div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;<span class="preprocessor">#include &quot;restclient-cpp/version.h&quot;</span></div>
<div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;</div>
<div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;<span class="keyword">namespace </span><a class="code" href="namespace_rest_client.html">RestClient</a> {</div>
<div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;</div>
<div class="line"><a name="l00026"></a><span class="lineno"><a class="line" href="namespace_rest_client_1_1_helpers.html">   26</a></span>&#160;<span class="keyword">namespace </span>Helpers {</div>
<div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;</div>
<div class="line"><a name="l00036"></a><span class="lineno"><a class="line" href="struct_rest_client_1_1_helpers_1_1_upload_object.html">   36</a></span>&#160;  <span class="keyword">typedef</span> <span class="keyword">struct </span>{</div>
<div class="line"><a name="l00037"></a><span class="lineno"><a class="line" href="struct_rest_client_1_1_helpers_1_1_upload_object.html#a0f0bebacc6bb930899ee9babadb92a31">   37</a></span>&#160;    <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="struct_rest_client_1_1_helpers_1_1_upload_object.html#a0f0bebacc6bb930899ee9babadb92a31">data</a>;</div>
<div class="line"><a name="l00038"></a><span class="lineno"><a class="line" href="struct_rest_client_1_1_helpers_1_1_upload_object.html#a8cfb479c87d4870a7e54e62dc0a3d3f6">   38</a></span>&#160;    <span class="keywordtype">size_t</span> <a class="code" href="struct_rest_client_1_1_helpers_1_1_upload_object.html#a8cfb479c87d4870a7e54e62dc0a3d3f6">length</a>;</div>
<div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;  } <a class="code" href="struct_rest_client_1_1_helpers_1_1_upload_object.html">UploadObject</a>;</div>
<div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;</div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;  <span class="comment">// writedata callback function</span></div>
<div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;  <span class="keywordtype">size_t</span> <a class="code" href="namespace_rest_client_1_1_helpers.html#a1dfc03258041ee29084ef9cf566ab836">write_callback</a>(<span class="keywordtype">void</span> *ptr, <span class="keywordtype">size_t</span> size, <span class="keywordtype">size_t</span> nmemb,</div>
<div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;                              <span class="keywordtype">void</span> *userdata);</div>
<div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;</div>
<div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;  <span class="comment">// header callback function</span></div>
<div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;  <span class="keywordtype">size_t</span> <a class="code" href="namespace_rest_client_1_1_helpers.html#a464be55c71cef59eebb53d922956a4d1">header_callback</a>(<span class="keywordtype">void</span> *ptr, <span class="keywordtype">size_t</span> size, <span class="keywordtype">size_t</span> nmemb,</div>
<div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;                                <span class="keywordtype">void</span> *userdata);</div>
<div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;  <span class="comment">// read callback function</span></div>
<div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;  <span class="keywordtype">size_t</span> <a class="code" href="namespace_rest_client_1_1_helpers.html#a1209e4977d76d9be7d8b40328bcb464d">read_callback</a>(<span class="keywordtype">void</span> *ptr, <span class="keywordtype">size_t</span> size, <span class="keywordtype">size_t</span> nmemb,</div>
<div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;                              <span class="keywordtype">void</span> *userdata);</div>
<div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;</div>
<div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;  <span class="comment">// trim from start</span></div>
<div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;  <span class="keyword">static</span> <span class="keyword">inline</span> std::string &amp;ltrim(std::string &amp;s) {  <span class="comment">// NOLINT</span></div>
<div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;    s.erase(s.begin(), std::find_if(s.begin(), s.end(),</div>
<div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;          std::not1(std::ptr_fun&lt;int, int&gt;(std::isspace))));</div>
<div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;    <span class="keywordflow">return</span> s;</div>
<div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;  }</div>
<div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;</div>
<div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;  <span class="comment">// trim from end</span></div>
<div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;  <span class="keyword">static</span> <span class="keyword">inline</span> std::string &amp;rtrim(std::string &amp;s) { <span class="comment">// NOLINT</span></div>
<div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;    s.erase(std::find_if(s.rbegin(), s.rend(),</div>
<div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;          std::not1(std::ptr_fun&lt;int, int&gt;(std::isspace))).base(), s.end());</div>
<div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;    <span class="keywordflow">return</span> s;</div>
<div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;  }</div>
<div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;</div>
<div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;  <span class="comment">// trim from both ends</span></div>
<div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;  <span class="keyword">static</span> <span class="keyword">inline</span> std::string &amp;trim(std::string &amp;s) {  <span class="comment">// NOLINT</span></div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;    <span class="keywordflow">return</span> ltrim(rtrim(s));</div>
<div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;  }</div>
<div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;};  <span class="comment">// namespace Helpers</span></div>
<div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;</div>
<div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;};  <span class="comment">// namespace RestClient</span></div>
<div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;</div>
<div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;<span class="preprocessor">#endif  // INCLUDE_RESTCLIENT_CPP_HELPERS_H_</span></div>
<div class="ttc" id="namespace_rest_client_1_1_helpers_html_a464be55c71cef59eebb53d922956a4d1"><div class="ttname"><a href="namespace_rest_client_1_1_helpers.html#a464be55c71cef59eebb53d922956a4d1">RestClient::Helpers::header_callback</a></div><div class="ttdeci">size_t header_callback(void *ptr, size_t size, size_t nmemb, void *userdata)</div><div class="ttdoc">header callback for libcurl </div><div class="ttdef"><b>Definition:</b> helpers.cc:41</div></div>
<div class="ttc" id="struct_rest_client_1_1_helpers_1_1_upload_object_html_a0f0bebacc6bb930899ee9babadb92a31"><div class="ttname"><a href="struct_rest_client_1_1_helpers_1_1_upload_object.html#a0f0bebacc6bb930899ee9babadb92a31">RestClient::Helpers::UploadObject::data</a></div><div class="ttdeci">const char * data</div><div class="ttdef"><b>Definition:</b> helpers.h:37</div></div>
<div class="ttc" id="namespace_rest_client_1_1_helpers_html_a1dfc03258041ee29084ef9cf566ab836"><div class="ttname"><a href="namespace_rest_client_1_1_helpers.html#a1dfc03258041ee29084ef9cf566ab836">RestClient::Helpers::write_callback</a></div><div class="ttdeci">size_t write_callback(void *ptr, size_t size, size_t nmemb, void *userdata)</div><div class="ttdoc">write callback function for libcurl </div><div class="ttdef"><b>Definition:</b> helpers.cc:23</div></div>
<div class="ttc" id="struct_rest_client_1_1_helpers_1_1_upload_object_html"><div class="ttname"><a href="struct_rest_client_1_1_helpers_1_1_upload_object.html">RestClient::Helpers::UploadObject</a></div><div class="ttdoc">This structure represents the payload to upload on POST requests. </div><div class="ttdef"><b>Definition:</b> helpers.h:36</div></div>
<div class="ttc" id="namespace_rest_client_1_1_helpers_html_a1209e4977d76d9be7d8b40328bcb464d"><div class="ttname"><a href="namespace_rest_client_1_1_helpers.html#a1209e4977d76d9be7d8b40328bcb464d">RestClient::Helpers::read_callback</a></div><div class="ttdeci">size_t read_callback(void *ptr, size_t size, size_t nmemb, void *userdata)</div><div class="ttdoc">read callback function for libcurl </div><div class="ttdef"><b>Definition:</b> helpers.cc:75</div></div>
<div class="ttc" id="struct_rest_client_1_1_helpers_1_1_upload_object_html_a8cfb479c87d4870a7e54e62dc0a3d3f6"><div class="ttname"><a href="struct_rest_client_1_1_helpers_1_1_upload_object.html#a8cfb479c87d4870a7e54e62dc0a3d3f6">RestClient::Helpers::UploadObject::length</a></div><div class="ttdeci">size_t length</div><div class="ttdef"><b>Definition:</b> helpers.h:38</div></div>
<div class="ttc" id="namespace_rest_client_html"><div class="ttname"><a href="namespace_rest_client.html">RestClient</a></div><div class="ttdoc">namespace for all RestClient definitions </div><div class="ttdef"><b>Definition:</b> connection.h:23</div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Fri Dec 2 2016 10:53:09 for restclient-cpp by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.9.1
</small></address>
</body>
</html>
